package tech.aistar.mapper;

import org.apache.ibatis.annotations.*;
import tech.aistar.entity.Pet;

import java.sql.Date;
import java.sql.Timestamp;
import java.util.List;

public interface PetMapper {
    //根据用户id属于他的所有宠物
    @Select("select * from pet where id=#{value} and p_status = 0")
    List<Pet> findAllById(Integer id);

    //查找特定宠物信息
    @Select("select * from pet where p_id = #{pId}")
    Pet findById(@Param("pId") Long pId);


//    修改宠物信息
    @Update("update pet set p_name = #{pName},p_age=#{pAge},p_sex=#{pSex},havepic=#{havepic},picurl=#{picurl},p_birthday=#{pBirthday},p_type = #{pType} where p_id =#{pId}")
    void editPet(@Param("pName") String pName, @Param("pAge") Integer pAge, @Param("pSex") Integer pSex, @Param("havepic")Integer havepic, @Param("picurl")String picurl, @Param("pBirthday") Date pBirthday, @Param("pType") Integer pType,@Param("pId") Long pId);

    //添加宠物信息
    @Insert("insert into pet values(#{pId},#{id},#{pName},#{pAge},#{pSex},0,#{picurl},#{pBirthday},#{pType},0)")
    void addPet(Pet pet);

    //删除宠物
    @Delete("update pet set p_status=1 where p_id = #{value}")
    void delPet(Long pId);
}
